package com.itheima.day09.Zuoye.ZuoYe4;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ZuoYe4 {
    public static void main(String[] args) {
        Set <String> set=new HashSet();
        List<String> list=List.of("王佳乐","张三丰","王思聪","张飞","刘晓敏","张靓颖","王敏");
        set.addAll( list);
        set.stream().filter(s->s.startsWith("张")).limit(2).forEach(System.out::println);
        System.out.println("---------");
        set.stream().filter(s->s.startsWith("王")).forEach(System.out::println);
        System.out.println("---------");
        set.stream().filter(s->s.startsWith("王")).skip(1).forEach(System.out::println);
        System.out.println("---------");
        List list1= set.stream().filter(s->s.startsWith("张")).collect(Collectors.toList());
        List list2= set.stream().filter(s->s.startsWith("王")).collect(Collectors.toList());
        Stream <String>stream2=Stream.concat(list1.stream(),list2.stream());
        stream2.filter(s->s.length()==3).forEach(System.out::println);

    }
}
